<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=1180,initial-scale=0,user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="renderer" content="webkit">
    <title>账户登录</title>
    <link rel="shortcut icon" th:href="${@lj.jsonKey(sysSystem.systemDesc,'systemLogo')}" type="image/x-icon">
    <link type="text/css" href="/static/papper/style/reset.css" rel="stylesheet">
    <link type="text/css" href="/static/papper/style/register.css?v=190312" rel="stylesheet">
    <script src="/static/okadmin/js/jquery.min.js" type="text/javascript"></script>
</head>
<body th:style="|background: url(${@lj.jsonKey(sysSystem.systemDesc,'systemBackground')}) no-repeat;
        background-size: 100% 100%;
        background-attachment: fixed;|">
<script>
    if (window != top) {
        top.location.href = window.location.href;
    }
</script>
<form name="loginForm" id="login_form" method="post" action="#">
    <h2 class="text-center" th:text="${sysSystem.systemName}">后台管理系统</h2>
    <div></div>
    <div class="div_user">
        <span></span>
        <input class="username" id="loginName" type="text" placeholder="请输入用户名或手机号码">
    </div>
    <div class="div_pw">
        <span></span>
        <input class="pw" id="loginPass" type="password" placeholder="请输入密码">
    </div>
    <div class="div_pw" id="captcha_box" style="">
        <span></span>
        <input class="captcha" id="checkNumber" type="text" placeholder="请输入图片验证码" onKeyUp="keyup();">
        <div style=" position: absolute; right: 4px;  top: 8px; cursor: pointer; border: none; background: none;">
            <img src="/kaptcha" onclick='this.src="/kaptcha?" + Math.random()' width="120" height="35">
        </div>
    </div>
    <div id="loginTips"></div>
    <div style="">
        <input id="loginButton" class="login_btn" type="button" value="登录" onclick="UserLogin();">
    </div>
</form>
<script>
    function keyup() {
        if (event.keyCode == 13) {
            event.returnValue = false;
            event.cancel = true;
            $("#loginButton").click();
        }
    }

    function UserLogin() {
        let j = $('.login_btn');
        let e = $('#loginTips');
        e.html("").hide();
        if (j.val() == '登录中...') return;
        j.val('登录中...');
        let loginName = $('#loginName').val();
        let loginPass = $('#loginPass').val();
        let checkNumber = $('#checkNumber').val();
        if (!loginName || !loginPass || !checkNumber) {
            j.val('登录');
            e.html('&nbsp; 缺少必填内容').show();
            return;
        }
        $.ajax({
            url: '/login',
            type: 'post',
            dataType: 'json',
            data: {
                loginName: loginName,
                loginPass: loginPass,
                checkNumber: checkNumber
            },
            success: function (rtnObj) {
                if (rtnObj.statusCode == 200) {
                    window.location.href = 'index';
                } else {
                    e.html('&nbsp; ' + rtnObj.message).show();
                    j.val('登录');
                }
            }
        });
    }
</script>
</body>
</html>